#!/bin/bash            

#---------------------------------------
# Bumpslide MXMLC Quickbuild  
#                                       
# This script was written by David Knape
# and is ispired by the FlashDevelop quick 
# build function. 
# 
# This allows you to put mxmlc arguments in 
# your app source file using a javadoc-like
# syntax (i.e. @mxmlc ...).  This is useful for 
# small test applets and other things that need
# to be compiled with mxmlc but aren't worth 
# using a fancier build system.
#
# The passed in file is searched for a line with 
# @mxmlc and uses whatever else it finds as the 
# arguments for running mxmlc.
#
# This was of course setup to run on mac.  Put it 
# in your bash path, and run from command line, or
# set it up as an external tool in Eclipse.
#   
# Eclipse Setup: External Tools Configuration... Program...
#   Location: /path/to/quickbuild 
#   Working Directory: ${container_loc}
#   Arguments: ${resource_loc}    
#  
# -dk
# 
# http://bumpslide.com
#---------------------------------------             
                      
# Where is your mxmlc binary?
MXMLC=/Users/tkdave/resources/flash/lib/flex3_sdk/bin/mxmlc 

# Stop on error
set -e; 
            
mxmlc_args=`awk -F @mxmlc '/@mxmlc/ {print $2}' $1`
output_file=${1%.*}.swf;               

echo "Running Command: mxmlc " $mxmlc_args $1;
$MXMLC $mxmlc_args $1;     

echo "Opening Output File: " $output_file;

#open $output_file;

# open with browser
#open -a 'Safari.app' $output_file;

# open with flash player
open -a 'FlashPlayer_debug_10.0.12.36.app' $output_file;